package com.wavehi.web;

import com.wavehi.pojo.User;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

/**
 * @Author WaveHi
 * @Date 16/9/2021 上午 10:31
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description
 */
@WebServlet(urlPatterns = "/eLDemoServlet", loadOnStartup = 1)
public class ELDemoServlet extends HttpServlet {

    public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
        //设置域对象
        String[] hobbies = {"Java", "MySQL", "JavaScript"};
        User user = new User(1L, "Tom", "qwerty", "wepqw@163.com", new Date(), hobbies);
        req.setAttribute("user", user);
        req.setAttribute("objects", new Object[0]);
        req.setAttribute("list", new ArrayList<String>());
        req.setAttribute("map", new HashMap<String, Integer>());
        //获取请求转发对象
        RequestDispatcher requestDispatcher = req.getRequestDispatcher("/page/useEL.jsp");
        //请求转发
        requestDispatcher.forward(req, res);
    }
}
